﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Guline.Web.LiveModels.Models;
using Guline.Web.LiveModels.DataContext;

namespace Guline.Web.Livechat.Controllers
{
    public class HomeController : Controller
    {
        private DataContext db = new DataContext();
        public ActionResult Index()
        {
            ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application.";

            return View();
        }

        public ActionResult About()
        {
            ViewBag.Message = "Your app description page.";

            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }

        public ActionResult livechatgetinfo(int idnv)
        {
            var kq = (from n in db.Users where n.ID == idnv select n).FirstOrDefault();
            string s = "";

            s += "<li class='BrandHCM c_title_chat_seo'>";
            s += "<div>";
            s += "<img class='avatarSale' title='" + kq.username + "' src='" + kq.image + "' width='48' height='64'>";
            s += "<p>Bạn đang trao đổi với</p>";
            s += "<p><b>" + kq.username + "</b></p>";
            s += "</div>";
            s += "</li>";
            s += "<li class='BrandHCM'>";
            s += "<div>";
            s += "<p><b>Vui lòng điền thông tin của quý khách:</b></p>";
            s += "<p>";
            s += "<input type='text' class='input_text c_username' placeholder='Nhập Tên...'>";
            s += "<input type='text' class='input_text c_email' placeholder='Nhập Email...'>";
            s += "</p>";
            s += "<p class='p_button_start_chat'>";
            s += "<input type='button' class='button-chat' value='Quay lại'>";
            s += "<input type='button' class='button-chat' value='Bắt đầu chat'  onclick='javascript: livechatgetchat(" + idnv + ");'>";
            s += "</p>";
            s += "</div>";
            s += "</li>";

            Response.Write(s);
            return null;
        }
        public ActionResult livechatgetchat(int idnv)
        {
            var kq = (from n in db.Users where n.ID == idnv select n).FirstOrDefault();
            string s = "";

            s += "<li class='BrandHCM c_title_chat_seo'>";
            s += "<div>";
            s += "<img class='avatarSale' title='" + kq.username + "' src='" + kq.image + "' width='48' height='64'>";
            s += "<p>Bạn đang trao đổi với</p>";
            s += "<p><b>" + kq.username + "</b></p>";
            s += "</div>";
            s += "</li>";
            s += "    <li class='BrandHCM c_hr'>";
            s += "        <div class='c_chat_content'>";


            s += "        </div>";
            s += "    </li>";
            s += "    <li>";
            s += "        <textarea class='c_input_text_chat'></textarea>";
            s += "        <input type='button' class='btn_chat' value='Gửi'/>";
            s += "        <div style='clear:both'></div>";
            s += "    </li>";

            Response.Write(s);
            return null;
        }
    }
}
